package com.example.baiduapi.Scoket.web.controller;

import com.example.baiduapi.Mapper.mysqlMapper.UserMapper;
import com.example.baiduapi.Util.EncPassword;
import com.example.baiduapi.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tokenController")
public class TokenController {


	@Resource
	private UserMapper userMapper;

	@Value("${accessToken:123456}")
    private String accessToken;

	@GetMapping("/check")
	public String check(String accessToken,String phone){
		UserInfo userInfoByPhone = userMapper.getUserInfoByLoginName(phone);
		System.out.println(userInfoByPhone);
		if (userInfoByPhone == null){
			return "fail";
		}
		String[] split = accessToken.split("￣￣");
  		String toekn = EncPassword.string2MD5(userInfoByPhone.getPassword());
		String result = toekn.equals(split[0]) ? "success" :"fail";
		return result;
	}
}
